class Solution {
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        int x = 0, y = 0, col = n;
        for(int i = 0; i < (n / 2); i++) {
            for (int j = 0; j < (n + 1) / 2; j++) { //只需要遍历到对应最后一个的前一个
                //注意下面的坐标的参照系都是每一圈，每四个转的起点
                int temp = matrix[i][j];
                matrix[i][j] = matrix[n - j - 1][i];
                matrix[n - j - 1][i] = matrix[n - 1 - i][n - 1 - j];
                matrix[n - 1 - i][n - 1 - j] = matrix[j][n - 1 - i];
                matrix[j][n - 1 - i] = temp;
            }
        }
    }
}